package com.ruijixiang.leetcode.everyday.leetcode2024.leetcode202408;

import java.util.HashMap;
import java.util.Map;

public class leetcode20240817 {
    public int minimumOperationsToMakeKPeriodic(String word, int k) {
        int len=word.length(),mxCnt=0;
        Map<String,Integer> map=new HashMap<>();
        for(int i=0;i<len;i+=k){
            String sub=word.substring(i,i+k);
            int count=map.getOrDefault(sub,0)+1;
            map.put(sub,count);
            mxCnt=Math.max(mxCnt,count);
        }
        return len/k-mxCnt;
    }
}
